#ifndef HASHMAP_H
#define HASHMAP_H

#include "list.h"

#ifdef __cplusplus
extern "C" {
#endif

enum hashmap_types {MEM_LOC, STRING};

typedef int (*hasher) (void *);
typedef int (*comparer) (void *, void *);

struct hashentry {
	void *key;
	void *value;
};

typedef struct {
	int capacity;
	int size;
	list_t **data;
	hasher hash;
	comparer compare;
} hashmap_t;

hashmap_t *make_hashmap(int);
void destroy_hasmap(hashmap_t *hashmap);

void hashmap_hash(hashmap_t *, hasher);
void hashmap_compare(hashmap_t *, comparer);

int hashmap_size(hashmap_t *);
int hashmap_capacity(hashmap_t *);

void *hashmap_set(hashmap_t *, void *, void *);
void *hashmap_remove(hashmap_t *, void *);
void *hashmap_get(hashmap_t *, void *);

/*
 * Set the hashmap type to one of several predefined types. Affects the hasher
 * and the comparer used.
 */
void hashmap_type(hashmap_t *, enum hashmap_types);

// TODO hashmap iterators



/*
 * Sample hashers and comparers.
 */
hasher string_hasher;
comparer string_comparer;

#ifdef __cplusplus
}
#endif

#endif /* !HASHMAP_H */

